home *** CD-ROM | disk | FTP | other *** search
/ Treccani Italiana Di Scienze Lettere Ed Arti / [Enciclopedia] Treccani Italiana di scienze lettere ed arti.iso / pc / data / xxi_appendice_dvd.swf / scripts / __Packages / HtmlTreeCellRenderer.as < prev    next >
Text File  |  2007-11-08  |  4KB  |  104 lines

  1. class HtmlTreeCellRenderer extends mx.core.UIComponent
  2. {
  3.    static var style_sheet = null;
  4.    static var USE_EMBEDDED_FONT = true;
  5.    static var ADD_DOT = false;
  6.    static var SPAN_BEFORE = "<span class=\'rowText\'>";
  7.    static var SPAN_AFTER = "</span>";
  8.    var previousLabel = null;
  9.    function HtmlTreeCellRenderer()
  10.    {
  11.       super();
  12.       if(HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI == undefined)
  13.       {
  14.          HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI = Array(" ill"," tab"," tabb"," fig"," cart"," segg"," diagr"," col"," mus");
  15.       }
  16.    }
  17.    function createChildren(Void)
  18.    {
  19.       if(HtmlTreeCellRenderer.CssUrl != undefined && HtmlTreeCellRenderer.style_sheet == null)
  20.       {
  21.          HtmlTreeCellRenderer.style_sheet = new TextField.StyleSheet();
  22.          HtmlTreeCellRenderer.style_sheet.load(HtmlTreeCellRenderer.CssUrl);
  23.       }
  24.       if(this.htmlComponent == undefined)
  25.       {
  26.          this.createLabel("htmlComponent",1);
  27.       }
  28.       this.htmlComponent.embedFonts = HtmlTreeCellRenderer.USE_EMBEDDED_FONT;
  29.       this.htmlComponent.html = true;
  30.       this.htmlComponent.border = false;
  31.       this.htmlComponent.multiline = false;
  32.       this.htmlComponent.wordWrap = false;
  33.       this.htmlComponent.selectable = false;
  34.       this.htmlComponent.background = false;
  35.       this.htmlComponent.styleSheet = HtmlTreeCellRenderer.style_sheet;
  36.       this.size();
  37.    }
  38.    function size(Void)
  39.    {
  40.       this.htmlComponent.setSize(this.__width - 2,this.__height);
  41.    }
  42.    function setValue(str, item, sel)
  43.    {
  44.       if(item == undefined)
  45.       {
  46.          this.htmlComponent.htmlText = this.HtmlFunction(str,"");
  47.          this.previousLabel = null;
  48.          return undefined;
  49.       }
  50.       var _loc3_ = this.columnIndex;
  51.       var _loc4_ = this.getDataLabel();
  52.       var _loc6_ = this.listOwner.getColumnAt(_loc3_).htmlFunction;
  53.       var _loc2_ = this.HtmlFunction(str,_loc4_);
  54.       if(_loc2_ != undefined)
  55.       {
  56.          if(_loc2_ != this.previousLabel)
  57.          {
  58.             this.htmlComponent.htmlText = this.previousLabel = HtmlTreeCellRenderer.SPAN_BEFORE + _loc2_ + HtmlTreeCellRenderer.SPAN_AFTER;
  59.          }
  60.       }
  61.       else
  62.       {
  63.          this.htmlComponent.htmlText = "";
  64.       }
  65.    }
  66.    function getPreferredHeight(Void)
  67.    {
  68.       if(this.owner == undefined)
  69.       {
  70.          return 18;
  71.       }
  72.       return this.owner.__height;
  73.    }
  74.    function HtmlFunction(inLabel, columnName)
  75.    {
  76.       var _loc2_ = inLabel;
  77.       _loc2_ = _loc2_.split("<sub>").join("<sub>");
  78.       _loc2_ = _loc2_.split("</sub>").join("</sub>");
  79.       _loc2_ = _loc2_.split("<sup>").join("<sup>");
  80.       _loc2_ = _loc2_.split("</sup>").join("</sup>");
  81.       _loc2_ = _loc2_.split("\\[").join("");
  82.       _loc2_ = _loc2_.split("\\]").join("");
  83.       if(_loc2_.indexOf("<sup>") >= 0 || _loc2_.indexOf("<sub>") >= 0)
  84.       {
  85.          _loc2_ = StringUtils.subSupFromHTML(_loc2_);
  86.       }
  87.       if(HtmlTreeCellRenderer.ADD_DOT)
  88.       {
  89.          var _loc3_ = _loc2_.length;
  90.          var _loc1_ = 0;
  91.          while(_loc1_ < HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI.length)
  92.          {
  93.             if(_loc2_.lastIndexOf(HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI[_loc1_]) == _loc3_ - HtmlTreeCellRenderer.ARRAY_ABBREVIAZIONI[_loc1_].length)
  94.             {
  95.                _loc2_ += ".";
  96.                break;
  97.             }
  98.             _loc1_ = _loc1_ + 1;
  99.          }
  100.       }
  101.       return _loc2_;
  102.    }
  103. }
  104.